home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00092_Misc.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  8.2 KB  |  325 lines

  1. on updateActors
  2.   global gActorList
  3.   set x to 1
  4.   repeat while count(gActorList) > 0
  5.     update(getAt(gActorList, x))
  6.     set x to x + 1
  7.     if x > count(gActorList) then
  8.       exit repeat
  9.     end if
  10.   end repeat
  11. end
  12.  
  13. on hideActor actorToHide
  14.   global gActorList, gHiddenActorList
  15.   add(gHiddenActorList, actorToHide)
  16.   deleteAt(gActorList, getPos(gActorList, actorToHide))
  17. end
  18.  
  19. on clearActor actorToClear
  20.   global gActorList
  21.   set actorPos to getPos(gActorList, actorToClear)
  22.   if actorPos <> 0 then
  23.     deleteAt(gActorList, actorPos)
  24.   end if
  25. end
  26.  
  27. on clearHiddenActor actorToClear
  28.   global gHiddenActorList
  29.   set actorPos to getPos(gHiddenActorList, actorToClear)
  30.   if actorPos <> 0 then
  31.     deleteAt(gHiddenActorList, actorPos)
  32.   end if
  33. end
  34.  
  35. on showActor actorToShow
  36.   global gActorList, gHiddenActorList
  37.   add(gActorList, actorToShow)
  38.   deleteAt(gHiddenActorList, getPos(gHiddenActorList, actorToShow))
  39. end
  40.  
  41. on hideOtherActors actorToKeep
  42.   global gActorList, gHiddenActorList
  43.   set gHiddenActorList to []
  44.   repeat while count(gActorList) > 1
  45.     if getPos(gActorList, actorToKeep) = 1 then
  46.       add(gHiddenActorList, getAt(gActorList, 2))
  47.       deleteAt(gActorList, 2)
  48.       next repeat
  49.     end if
  50.     add(gHiddenActorList, getAt(gActorList, 1))
  51.     deleteAt(gActorList, 1)
  52.   end repeat
  53. end
  54.  
  55. on hideAllActors
  56.   global gActorList, gHiddenActorList
  57.   repeat with actor in gActorList
  58.     add(gHiddenActorList, actor)
  59.   end repeat
  60.   set gActorList to []
  61. end
  62.  
  63. on showAllActors
  64.   global gActorList, gHiddenActorList
  65.   repeat with actor in gHiddenActorList
  66.     add(gActorList, actor)
  67.   end repeat
  68.   set gHiddenActorList to []
  69. end
  70.  
  71. on clearAllActors
  72.   global gActorList, gHiddenActorList, gRollAnimButton, gLoopButton
  73.   set gActorList to []
  74.   set gHiddenActorList to []
  75.   set gRollAnimButton to EMPTY
  76.   set gLoopButton to EMPTY
  77. end
  78.  
  79. on animateSprite spriteNum, destPoint, speed
  80.   set startx to the locH of sprite spriteNum
  81.   set starty to the locV of sprite spriteNum
  82.   set endx to getAt(destPoint, 1)
  83.   set endy to getAt(destPoint, 2)
  84.   if (startx = endx) and (starty = endy) then
  85.     exit
  86.   end if
  87.   set dist to sqrt(power(endx - startx, 2) + power(endy - starty, 2))
  88.   set stepNumber to dist / speed
  89.   set deltaX to (endx - startx) / stepNumber
  90.   set deltaY to (endy - starty) / stepNumber
  91.   repeat with x = 1 to integer(stepNumber)
  92.     set the locH of sprite spriteNum to startx + (x * deltaX)
  93.     set the locV of sprite spriteNum to starty + (x * deltaY)
  94.     updateStage()
  95.   end repeat
  96.   set the locH of sprite spriteNum to endx
  97.   set the locV of sprite spriteNum to endy
  98.   updateStage()
  99. end
  100.  
  101. on shuffleList originalList
  102.   set shuffledList to []
  103.   repeat while count(originalList) > 0
  104.     set index to random(count(originalList))
  105.     add(shuffledList, getAt(originalList, index))
  106.     deleteAt(originalList, index)
  107.   end repeat
  108.   return shuffledList
  109. end
  110.  
  111. on getPropPos someList, someProp
  112.   set propPos to 0
  113.   repeat with x = 1 to count(someList)
  114.     set propName to getPropAt(someList, x)
  115.     if propName = someProp then
  116.       set propPos to x
  117.       exit repeat
  118.     end if
  119.   end repeat
  120.   return propPos
  121. end
  122.  
  123. on puppetAll
  124.   repeat with x = 1 to 48
  125.     puppetSprite(x, 1)
  126.   end repeat
  127. end
  128.  
  129. on unpuppetAll
  130.   repeat with x = 1 to 48
  131.     puppetSprite(x, 0)
  132.   end repeat
  133. end
  134.  
  135. on removeSprite channel
  136.   global gPoint
  137.   set the castNum of sprite channel to gPoint
  138.   set the locH of sprite channel to 1000
  139. end
  140.  
  141. on getBoundRect castNumber, bgChannel
  142.   if bgChannel = 0 then
  143.     set bgRect to rect(0, 0, the stageRight - the stageLeft, the stageBottom - the stageTop)
  144.   else
  145.     set bgRect to the rect of sprite bgChannel
  146.   end if
  147.   set bmapReg to the regPoint of cast castNumber
  148.   set bmapRect to the rect of cast castNumber
  149.   set left to getAt(bmapReg, 1) - getAt(bmapRect, 1)
  150.   set top to getAt(bmapReg, 2) - getAt(bmapRect, 2)
  151.   set right to getAt(bmapRect, 3) - getAt(bmapReg, 1)
  152.   set bottom to getAt(bmapRect, 4) - getAt(bmapReg, 2)
  153.   set boundRect to rect(getAt(bgRect, 1) + left, getAt(bgRect, 2) + top, getAt(bgRect, 3) - right, getAt(bgRect, 4) - bottom)
  154.   return boundRect
  155. end
  156.  
  157. on getKernValue castNumber
  158.   set bmapReg to the regPoint of cast castNumber
  159.   set bmapRect to the rect of cast castNumber
  160.   set kernValue to getAt(bmapRect, 3) - getAt(bmapReg, 1)
  161.   set castName to the name of cast castNumber
  162.   if getSuffix(castName) = "lower" then
  163.     set kernValue to kernValue - 3
  164.   else
  165.     if getSuffix(castName) = "upper" then
  166.       set kernValue to kernValue - 4
  167.     end if
  168.   end if
  169.   return kernValue
  170. end
  171.  
  172. on getSuffix stringData
  173.   return char offset(".", stringData) + 1 to length(stringData) of stringData
  174. end
  175.  
  176. on stripSuffix stringData
  177.   return char 1 to offset(".", stringData) - 1 of stringData
  178. end
  179.  
  180. on makePointList startChannel, howManyChannels
  181.   set pointList to []
  182.   repeat with channel = startChannel to startChannel + howManyChannels - 1
  183.     add(pointList, point(the locH of sprite channel, the locV of sprite channel))
  184.   end repeat
  185.   return pointList
  186. end
  187.  
  188. on startBuffering
  189.   global gFlushObject, gCPU
  190.   if gCPU = #Windows then
  191.     gFlushObject(mBufferEvents)
  192.   end if
  193. end
  194.  
  195. on flushBuffer
  196.   global gFlushObject, gCPU
  197.   if gCPU = #Mac then
  198.     gFlushObject(mFlush)
  199.   else
  200.     gFlushObject(mFlushEvents)
  201.   end if
  202. end
  203.  
  204. on paletteFix
  205.   global gFixpal, gCPU
  206.   if gCPU = #Mac then
  207.     gFixpal(mPatchIt)
  208.   end if
  209. end
  210.  
  211. on printBitmap whichCast
  212.   global gCPU, gXobjPath
  213.   if gCPU = #Mac then
  214.     set XObjFile to "pmatic.xobj"
  215.   else
  216.     set XObjFile to "pmatic.dll"
  217.   end if
  218.   openXLib(gXobjPath & XObjFile)
  219.   set printerObject to PrintOMatic(mnew)
  220.   if not objectp(printerObject) then
  221.     alert("There is no currently selected printer. Printing features are disabled.")
  222.   else
  223.     printerObject(mRegister, "PMAT130-235-01341")
  224.     set w to the width of cast whichCast
  225.     set h to the height of cast whichCast
  226.     printerObject(mSetLandscapeMode, 1)
  227.     set pw to printerObject(mGetPageWidth)
  228.     set ph to printerObject(mGetPageHeight)
  229.     set scaling to min(float(pw) / float(w), float(ph) / float(h))
  230.     set scaling to min(scaling, 1.0)
  231.     set w to integer(w * scaling)
  232.     set h to integer(h * scaling)
  233.     set left to (pw - w) / 2
  234.     set top to (ph - h) / 2
  235.     printerObject(mNewPage)
  236.     printerObject(mPicture, the picture of cast whichCast, left, top, left + w, top + h)
  237.     if printerObject(mDoJobSetup) = 1 then
  238.       updateStage()
  239.       printerObject(mPrint)
  240.     end if
  241.     printerObject(mdispose)
  242.   end if
  243.   closeXLib(gXobjPath & XObjFile)
  244. end
  245.  
  246. on copyScreenRegion boundSprite
  247.   global gCPU, gCopyObj, gSavePicHandle
  248.   if objectp(gCopyObj) then
  249.     gCopyObj(mdispose)
  250.   end if
  251.   set top to the top of sprite boundSprite
  252.   set left to the left of sprite boundSprite
  253.   set bottom to the bottom of sprite boundSprite
  254.   set right to the right of sprite boundSprite
  255.   if gCPU = #Mac then
  256.     set gCopyObj to StageToCast(mnew, top, left, bottom, right)
  257.     set gSavePicHandle to the picture of cast "LineArtTemp"
  258.     set the picture of cast "LineArtTemp" to gCopyObj(mGetHandle)
  259.   else
  260.     set tempCast to the number of cast "LineArtTemp"
  261.     set gCopyObj to ScreenCapture(mnew)
  262.     gCopyObj(mCpyScrnToClipbrd, left, top, right, bottom)
  263.     pasteClipBoardInto(cast tempCast)
  264.     updateStage()
  265.     set the name of cast tempCast to "LineArtTemp"
  266.   end if
  267. end
  268.  
  269. on resetCastMember
  270.   global gCPU, gSavePicHandle
  271.   if gCPU = #Mac then
  272.     set the picture of cast "LineArtTemp" to gSavePicHandle
  273.   else
  274.     set the picture of cast "LineArtTemp" to the picture of cast "Point"
  275.   end if
  276. end
  277.  
  278. on createCDpath volumeName, diskIDfilePath
  279.   global gCDpath
  280.   if the machineType = 256 then
  281.     repeat with i = 66 to 90
  282.       set drive to numToChar(i)
  283.       set fullPath to string(drive & ":\" & diskIDfilePath)
  284.       set myFile to FileIO(mnew, "read", fullPath)
  285.       if objectp(myFile) then
  286.         myFile(mdispose)
  287.         return drive & ":"
  288.         exit
  289.       end if
  290.     end repeat
  291.     return 0
  292.   else
  293.     set fullPath to volumeName & ":" & diskIDfilePath
  294.     set myFile to FileIO(mnew, "read", fullPath)
  295.     if objectp(myFile) then
  296.       myFile(mdispose)
  297.       return volumeName & ":"
  298.       exit
  299.     end if
  300.     return 0
  301.   end if
  302. end
  303.  
  304. on min a, b
  305.   if a < b then
  306.     return a
  307.   else
  308.     return b
  309.   end if
  310. end
  311.  
  312. on playSound soundName
  313.   puppetSound(soundName)
  314.   updateStage()
  315.   repeat while soundBusy(1)
  316.   end repeat
  317.   puppetSound(0)
  318. end
  319.  
  320. on bugDelay
  321.   startTimer()
  322.   repeat while the timer < 200
  323.   end repeat
  324. end
  325.